package demo.api.enterprise;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import util.HttpClientUtil;

/**
 * 4.12	获取文档待签数据
 * 将印章数据放入源PDF文档中，并生成文档待签属性，可使用数字证书对该值进行数字签名，签名方式采用 PKCS7#Detach
 * @throws IOException
 */
public class FileMerge {
	private static String appKey = "cAwut4VATycNMq17NZeFUD63pe83l2OJ";
    private static String appSecrty = "3BAlrfr7lW8kwlCMfo1dXS8Syn5q5qjS";
    private static String baseUrl = "http://smp-test.szitrus.com.cn/smp-api";
    private static String api = "/api/enterprise/file/merge";

	public static void main(String[] args) throws IOException {
		String url = baseUrl.concat(api);
		Map<String, String> params = new HashMap<>();

		params.put("signature_id", "121483639165812736");//filedigest()返回的签署事务编号,
	    params.put("signing_time", "2020-05-21 21:48:16");
	    params.put("signature_value", "MIIGBAYJKoZIhvcNAQcCoIIF9TCCBfECAQAxCzAJBgUrDgMCGgUAMAMGAQCgggQZMIIEFTCCAv2gAwIBAgIUcbzFNQad8MtLzqY0E311PTsfxIYwDQYJKoZIhvcNAQEFBQAwezELMAkGA1UEBhMCQ04xEzARBgNVBAoMCmlUcnVzQ2hpbmExHDAaBgNVBAsME0NoaW5hIFRydXN0IE5ldHdvcmsxOTA3BgNVBAMMMGlUcnVzQ2hpbmEgQ2xhc3MgMiBFbnRlcnByaXNlIFN1YnNjcmliZXIgQ0EgLSBHMzAeFw0xOTAyMTQwODIwMDdaFw0yMDAyMTQwODIwMDdaMIGEMRwwGgYJKoZIhvcNAQkBFg1odWpsQHRmYjguY29tMScwJQYDVQQDDB7lpKnkuIvmlK/ku5jnp5HmioDmnInpmZDlhazlj7gxEjAQBgNVBAsMCei/kOe7tOmDqDEnMCUGA1UECgwe5aSp5LiL5pSv5LuY56eR5oqA5pyJ6ZmQ5YWs5Y+4MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+hUGrbK9k3jAJg7vljn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QTfXU9Ox/EhjAJBgUrDgMCGgUAMA0GCSqGSIb3DQEBAQUABIIBAAUXylbysLh2FGEisTrQ6WbMFwVXxV9evv2dFZa006Nsg77fkOgcxxde2c4e+Jn5eWlxYXl2PMJIrRvyFm9FxDnqFlqe5PZ2B3WTnKJ4V543eK3VDrXxG/0sbZk+GL9VodHZ11KYvvYS9WIPC1ykVyPTukPuB7+tM2/vc/C2LAxi2RyUEPTaLch91J1GxTAwoHlILQ30LI0A6fiQl0H9V0AQcBMG1OGwTAcqQ65coeeLFe9NzhJhNI1V132BBlbQ+rDYIJnyGNMhpYfljMpaC8gBl+LTI+Gc516npfgWeBIwwp8PQoIpqAlseQr60NKOJzwjTHvTemaCytvurxNA22k=");
	        
	    String resStr =  HttpClientUtil.getResponse(url, params, appKey, appSecrty);
	    JSONObject resJson = JSON.parseObject(resStr);	
	    System.out.println(resJson);
	}
}
